package nickthissen.iracing.datamodels;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.Arrays;

import com.google.gson.Gson;

public class RecentThread extends Thread implements Serializable
{
	/**
	 * 
	 */
	private static final long serialVersionUID = -4959284665626561979L;
//	public int Id;
//	public String Url;
	public String ForumName;
	public String ForumUrl;
	public int ForumId;
	public String ForumAbbreviation;
//	public String LastPageUrl;
//	public int PageCount;
//	public String Title;
//	public String Author;
//	public String AuthorUrl;
//	public int Replies;
//	public int Views;
//	public long LastMessageTime;
//	public String LastMessageUser;
//	public String LastMessageUserUrl;  
//    public String IconName;
//    public boolean IsPoll;
//	
//    public boolean isUnread()
//    {
//    	if (this.IconName == null) return false;
//    	return this.IconName.contains("unread");
//    }
    
	public static RecentThread fromJson(String json)
	{
		Gson g = new Gson();
		RecentThreadDataModel data = g.fromJson(json, RecentThreadDataModel.class);
		return data.d;
	}
	
//	public static ArrayList<RecentThread> getListFromJson(String json)
//	{
//		Gson g = new Gson();
//		RecentThreadListDataModel data = g.fromJson(json, RecentThreadListDataModel.class);
//		return new ArrayList<RecentThread>(Arrays.asList(data.d));
//	}
	
	private class RecentThreadDataModel
	{
		public RecentThread d;
	}
	
	private class RecentThreadListDataModel
	{
		public RecentThread d[];
	}
}
